package cn.edu.ujn.lab3.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.ujn.lab3.dao.User;
import cn.edu.ujn.lab3.dao.UserExample;
import cn.edu.ujn.lab3.dao.UserExample.Criteria;
import cn.edu.ujn.lab3.dao.UserMapper;
@Service("userService")
@Transactional
public class UserServiceImpl implements IUserService {
	@Autowired
	private UserMapper userdao;

	@Override
	public User findUser(User user) {
		// TODO Auto-generated method stub
		UserExample userExample = new UserExample();
		Criteria criteria = userExample.createCriteria();
		criteria.andUserCodeEqualTo(user.getUserCode()).andUserPasswordEqualTo(user.getUserPassword());
		List<User> result = userdao.selectByExample(userExample);
		if(result.size()>0)
			return result.get(0);
		else
			return null;
	}

}
